import java.util.Scanner;

//阶乘
public class Factorial {
    public static void main(String[] args) {
        System.out.println(factorial(10));
        System.out.println(factorial2(10));
    }

    //第一种使用动态规划（装逼
    public static int factorial(int n){
        int num[] = new int[10+1];
        num[0] = 1;
        num[1] = 1;
        for (int i = 2; i <= n; i++) {
            num[i] = i*num[i-1];
        }
        return num[n];
    }

    //一般来说就是这么写的
    public static int factorial2(int n){
        int sum = 1;
        for (int i = 1; i <= n; i++) {
            sum*=i;
        }
        return sum;
    }
}
